package 数组.easy;

/**
 * @author Lw中
 * @date 2020/8/13 9:49
 */
public class YiYiBaWu {

    public static String dayOfTheWeek(int day, int month, int year) {
        int sum = 0;
        for(int i = 1971;i<year;i++) {
            if(i%4==0 && i%100!=0 || i%400==0) {
                sum+=366;
            }else {
                sum+=365;
            }
        }

        if(year%4==0 && year%100!=0 || year%400==0) {
            int[] yue = {31,29,31,30,31,30,31,31,30,31,30,31};
            for(int i = 0;i<month-1;i++) {
                sum+=yue[i];
            }
        }else {
            int[] yue = {31,28,31,30,31,30,31,31,30,31,30,31};
            for(int i = 0;i<month-1;i++) {
                sum+=yue[i];
            }
        }
        sum+=day-1;
        sum = sum%7;
        // 1971的第一天是星期五，所以设星期五为一周的开始
        String[] arr = {"Friday","Saturday","Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"};
        return arr[sum];
    }

    public static void main(String[] args) {
        String s = dayOfTheWeek(31, 8, 2019);
        System.out.println(s);
    }

}
